package com.pet.pet.utlis;
import java.util.HashMap;
import java.util.Map;

/**
 * 用来返回给前端
 */
public class UPetUnifiedV extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public UPetUnifiedV() {
        put("code", 0);
        put("msg", "success");
    }

    public static UPetUnifiedV error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static UPetUnifiedV error(String msg) {
        return error(500, msg);
    }

    public static UPetUnifiedV error(int code, String msg) {
        UPetUnifiedV r = new UPetUnifiedV();
        r.put("code", code);
        r.put("msg", msg);
        return r;
    }

    public static UPetUnifiedV success(String msg) {
        UPetUnifiedV r = new UPetUnifiedV();
        r.put("msg", msg);
        return r;
    }

    public static UPetUnifiedV success(Map<String, Object> map) {
        UPetUnifiedV r = new UPetUnifiedV();
        r.putAll(map);
        return r;
    }

    public static UPetUnifiedV ok() {
        return new UPetUnifiedV();
    }

    public UPetUnifiedV put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}

